package com.laiketui.app.services.dubbo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.github.benmanes.caffeine.cache.Cache;
import com.laiketui.app.api.IndexService;
import com.laiketui.app.common.consts.AppConst;
import com.laiketui.common.api.*;
import com.laiketui.common.api.distribution.PubliceDistributionService;
import com.laiketui.common.api.plugin.*;
import com.laiketui.common.mapper.*;
import com.laiketui.common.utils.tool.cache.RedisDataTool;
import com.laiketui.common.utils.tool.data.DataCheckTool;
import com.laiketui.common.utils.tool.data.GoodsDataUtils;
import com.laiketui.common.utils.tool.str.StringUtils;
import com.laiketui.core.cache.RedisUtil;
import com.laiketui.core.common.SplitUtils;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.core.lktconst.GloabConst;
import com.laiketui.core.utils.tool.DataUtils;
import com.laiketui.core.utils.tool.DateUtil;
import com.laiketui.core.utils.tool.PinyinUtils;
import com.laiketui.core.utils.tool.SerializePhpUtils;
import com.laiketui.domain.config.*;
import com.laiketui.domain.coupon.CouponConfigModel;
import com.laiketui.domain.home.SystemMessageModel;
import com.laiketui.domain.lktconst.DictionaryConst;
import com.laiketui.domain.lktconst.ErrorCode;
import com.laiketui.domain.mch.MchConfigModel;
import com.laiketui.domain.mch.UserCollectionModel;
import com.laiketui.domain.nodatamodel.StdClass;
import com.laiketui.domain.product.GroupProductModel;
import com.laiketui.domain.product.ProductClassModel;
import com.laiketui.domain.seckill.SecondsConfigModel;
import com.laiketui.domain.systems.SystemTellModel;
import com.laiketui.domain.user.User;
import com.laiketui.domain.vo.MainVo;
import com.laiketui.domain.vo.PageModel;
import com.laiketui.root.annotation.DubboApiMethod;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.*;

/**
 * 首页实现
 *
 * @author Trick
 * @date 2020/10/10 9:22
 */
@DubboService(version = "1.0.0")
public class IndexDubboServiceImpl implements IndexService {

    private final Logger logger = LoggerFactory.getLogger(IndexDubboServiceImpl.class);

    private final String NEARBY_KEY = "user_nearby";

    @Autowired
    private Cache<String, Object> caffeineCache;

    /**
     * 首页分类商品 ：30秒更新一次
     */
    private final Integer HOME_PAGE_CLASS_CACHE_TIME = 30;

    @Override
    public boolean hasDiy(Integer storeId) throws LaiKeAPIException {
        try {
            return publicService.frontPlugin(storeId, DictionaryConst.Plugin.DIY, null);
        } catch (Exception e) {
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "hasDiy");
        }
    }

    @Override
    public Map<String, Object> pluginStatus(MainVo vo, Integer mchId) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            //插件状态
            Map<String, Integer> pluginMap = new HashMap<>(16);
            List<String> pluginCodeList = pluginsModelMapper.getPluginsCodeAll(vo.getStoreId());
            for (String pluginCode : pluginCodeList) {
                publicService.frontPlugin(vo.getStoreId(), mchId, pluginCode, pluginMap);
            }
            resultMap.put("plugin", pluginMap);
        } catch (Exception e) {
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "pluginStatus");
        }
        return resultMap;
    }


    //会员标志
    String MEMBER_SHIP_STATUS_CACHE_KEY = "com.laike.app.get_membership_status_cache_";

    @DubboApiMethod(apiKey = "com.laike.app.get_membership_status",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public Map<String, Object> getMembershipStatus(int storeId) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            boolean status = false;
            String key = MEMBER_SHIP_STATUS_CACHE_KEY + storeId;
            caffeineCache.getIfPresent(key);
            Object cacheStatus = caffeineCache.asMap().get(key);
            if (cacheStatus == null) {
                BigDecimal userGrate = publicService.getUserGradeRate(storeId, null);
                if (userGrate != null && userGrate.compareTo(new BigDecimal("1")) != 0) {
                    status = true;
                    caffeineCache.put(key, status);
                }
            } else {
                status = (Boolean) cacheStatus;
            }
            resultMap.put("membership_status", status);
        } catch (Exception e) {
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "getMembershipStatus");
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> classList(MainVo vo) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            //小程序商品分类集
            List<Map<String, Object>> appList = new ArrayList<>();
            User user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, false);
            //获取会员等级
            BigDecimal gradeRate = BigDecimal.ONE;
            if (user != null) {
                gradeRate = getMemberGrade(vo.getStoreId(), user);
            }
            //产品配置 是否显示下架商品
            List<Integer> GoodsStatus = new ArrayList<>();
            GoodsStatus.add(DictionaryConst.GoodsStatus.NEW_GROUNDING);
            ProductModel productModel = new ProductModel();
            productModel.setStore_id(vo.getStoreId());
            productModel = productModelMapper.selectOne(productModel);
            if (productModel != null) {
                if (ProductConfigModel.DISPLAY_BEAN_GOODS.equals(productModel.getIs_open())) {
                    //显示已下架商品
                    GoodsStatus.add(DictionaryConst.GoodsStatus.OFFLINE_GROUNDING);
                }
            }
            //查询商品并分类显示返回JSON至小程序
            List<ProductClassModel> productClassModels = productClassModelMapper.getProduct(vo.getStoreId());
            if (productClassModels != null) {
                for (ProductClassModel productClass : productClassModels) {
                    Map<String, Object> appMap = new HashMap<>(16);
                    //获取商品
                    Map<String, Object> parmaMap1 = new HashMap<>(16);
                    parmaMap1.put("store_id", vo.getStoreId());
                    parmaMap1.put("GoodsStatus", GoodsStatus);
                    parmaMap1.put("cid", productClass.getCid());
                    parmaMap1.put("sort_sort", DataUtils.Sort.DESC.toString());
                    if (productModel != null && productModel.getIs_display_sell_put() == 0) {
                        //不展示已售罄的商品
                        parmaMap1.put("stockNum", "stockNum");
                    }

                    parmaMap1.put("page", 0);
                    parmaMap1.put("pageSize", 10);
                    List<Map<String, Object>> productListModels = productListModelMapper.getProductList(parmaMap1);
                    //商品信息逻辑处理
                    List<Map<String, Object>> resultProductMap = getGoodsInfo(vo.getStoreId(), gradeRate, productListModels);
                    appMap.put("list", resultProductMap);
                    appMap.put("cid", productClass.getCid());
                    appMap.put("english_name", productClass.getEnglish_name());
                    appMap.put("pname", productClass.getPname());
                    appList.add(appMap);
                }
            }
            resultMap.put("list", appList);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取分类列表 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "classList");
        }
        return resultMap;
    }

    //换成商城店铺配置信息
    String MCH_CONFIG_CACHE_KEY = "MCH_CONFIG_INFO_";
    //如果是相同的经纬度则从缓存中拿不去调用接口
    String USER_LON_LAT = "USER_LON_LAT_";

    @DubboApiMethod(apiKey = "com.laike.app.index",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public Map<String, Object> index(@NotNull int storeId, String accessId, @NotNull String storeType,
                                     @NotNull String language, @NotNull String longitude, @NotNull String latitude) throws LaiKeAPIException {
        User user;
        Map<String, Object> resultMap = new HashMap<>(16);
        //系统消息未读数量
        int messageNum = 0;
        //会员折扣
        BigDecimal gradeRate = BigDecimal.ONE;
        //是否享受折扣
        BigDecimal isGradeRate = BigDecimal.ZERO;
        //小程序商品分类集
        List<Map<String, Object>> appList = new ArrayList<>();
        int islogin = 0;
        try {
            //获取店铺配置
            ConfigModel configModel = null;
            //换成商城店铺配置信息
            String mchConfigCacheKey = MCH_CONFIG_CACHE_KEY + storeId;
            caffeineCache.getIfPresent(mchConfigCacheKey);
            configModel = (ConfigModel) caffeineCache.asMap().get(MCH_CONFIG_CACHE_KEY);
            if (configModel == null) {
                configModel = new ConfigModel();
                configModel.setStore_id(storeId);
                configModel = configModelMapper.selectOne(configModel);
                if (configModel == null) {
                    throw new LaiKeAPIException(ErrorCode.BizErrorCode.DATA_NOT_EXIST, "请先配置商城");
                }
                caffeineCache.put(mchConfigCacheKey, configModel);
            }

            //获取位置
            Map<String, Object> currentMap = new HashMap<>(16);
//            try {
//                //获取当前位置
//                String latLongCacheKey = USER_LON_LAT + accessId;
//                String region = (String) caffeineCache.asMap().get(latLongCacheKey);
//                if (region == null) {
//                    region = TengxunMapUtil.getAddress(configModel.getTencent_key(), latitude, longitude);
//                    logger.info("接口获取地区信息：{}", region);
//                    caffeineCache.put(latLongCacheKey, region);
//                }
//
//                if (StringUtils.isNotEmpty(region)) {
//                    logger.info("地区信息：{}", region);
//                    JSONObject resultGpsMap = JSONObject.parseObject(region);
//                    AdminCgModel adminCgModel = new AdminCgModel();
//                    String shen = resultGpsMap.getJSONObject("address_component").get("province") + "";
//                    adminCgModel.setG_ParentID(0);
//                    adminCgModel.setG_Level(2);
//                    adminCgModel.setG_CName(shen);
//                    AdminCgModel cgShen = adminCgModelMapper.selectOne(adminCgModel);
//                    String shi = resultGpsMap.getJSONObject("address_component").get("city") + "";
//
//                    if (cgShen != null) {
//                        logger.info("地区信息 省：{}", cgShen.getG_CName());
//                        adminCgModel.setG_ParentID(cgShen.getGroupID());
//                    }
//                    adminCgModel.setG_Level(3);
//                    adminCgModel.setG_CName(shi);
//                    AdminCgModel cgShi = adminCgModelMapper.selectOne(adminCgModel);
//                    //可能为空AuctionPayServiceImpl
//                    String qu = resultGpsMap.getJSONObject("address_component").get("district") + "";
//                    AdminCgModel cgQu = new AdminCgModel();
//                    if (StringUtils.isNotEmpty(region)) {
//                        if (cgShi != null) {
//                            logger.info("地区信息 市、县、区：{}", cgShen.getG_CName());
//                            adminCgModel.setG_ParentID(cgShi.getGroupID());
//                        }
//                        adminCgModel.setG_Level(4);
//                        adminCgModel.setG_CName(qu);
//                        cgQu = adminCgModelMapper.selectOne(adminCgModel);
//                    }
//
//                    if (cgShen != null) {
//                        currentMap.put("province", cgShen.getG_CName());
//                        currentMap.put("province_GroupID", cgShen.getGroupID());
//                    }
//                    if (cgShi != null) {
//                        currentMap.put("city", cgShi.getG_CName());
//                        currentMap.put("city_GroupID", cgShi.getGroupID());
//                    } else {
//                        if (cgShen != null) {
//                            currentMap.put("city", cgShen.getG_CName());
//                            currentMap.put("city_GroupID", cgShen.getGroupID());
//                        }
//                    }
//
//                    if (cgQu != null) {
//                        currentMap.put("district", cgQu.getG_CName() == null ? "" : cgQu.getG_CName());
//                        currentMap.put("district_GroupID", cgQu.getGroupID() == null ? "" : cgQu.getGroupID());
//                    }
//
//                }
//            } catch (LaiKeAPIException le) {
//                le.printStackTrace();
//            }

            //需登录的流程
            user = RedisDataTool.getRedisUserCache(accessId, redisUtil, false);
            gradeRate = getMemberGrade(storeId, user);
            if (user != null) {
                islogin = 1;
                //获取会员等级
//                gradeRate = BigDecimal.valueOf(publicMemberService.getMemberGradeRate(null, user.getUser_id(), storeId));
                //对token进行签名认证
                boolean isTokenInvalid = DataCheckTool.verifyToken(configModel, user);
                if (isTokenInvalid) {
                    //未过期 获取该会员未读的系统消息
                    SystemMessageModel systemMessageModel = new SystemMessageModel();
                    systemMessageModel.setStore_id(storeId);
                    systemMessageModel.setRecipientid(user.getUser_id());
                    systemMessageModel.setType(GloabConst.LktConfig.SYSMESSAGE_NOT_READ);
                    messageNum = systemMessageModelMapper.selectCount(systemMessageModel);
                }
            }

            //未登录则获取最低折扣用于显示
            if (gradeRate.compareTo(new BigDecimal("1")) == 0) {
                gradeRate = getMemberGrade(storeId, user);
            } else {
                //享受折扣
                isGradeRate = isGradeRate.add(gradeRate);
            }

            //获取附近店铺距离 默认显示三个
            List<String> mchList = new ArrayList<>();
            List<Map<String, Object>> mchStoreAllList = new ArrayList<>();
            Integer userMchId = null;
            if (user != null) {
                userMchId = user.getMchId();
            }
            MchConfigModel mchConfigModel = new MchConfigModel();
            mchConfigModel.setStore_id(storeId);
            mchConfigModel.setMch_id(customerModelMapper.getStoreMchId(storeId));
            mchConfigModel = mchConfigModelMapper.selectOne(mchConfigModel);
            if (mchConfigModel != null && mchConfigModel.getIs_display() == DictionaryConst.WhetherMaven.WHETHER_OK) {
                //38558禅道优化
                Map<String, Object> paramMap = new HashMap<>(16);
                paramMap.put("store_id", storeId);
                paramMap.put("recovery", DictionaryConst.ProductRecycle.NOT_STATUS);
                paramMap.put("review_status", DictionaryConst.ExameStatus.EXAME_PASS_STATUS);
                paramMap.put("is_lock", String.valueOf(DictionaryConst.WhetherMaven.WHETHER_NO));
                paramMap.put("collection_num_sort", DataUtils.Sort.DESC.toString());
                paramMap.put("add_time_sort", DataUtils.Sort.DESC.toString());
                List<Map<String, Object>> mchUserInfos = mchModelMapper.getMchUserInfo(paramMap);
                if (mchUserInfos != null && mchUserInfos.size() > 0){
                    for (Map<String, Object> mchUserInfo : mchUserInfos){
                        Map<String, Object> mchMap = new HashMap<>(16);
                        //获取商户logo图片地址
                        String logo = MapUtils.getString(mchUserInfo, "logo");
                        String imgLogoUrl = publicService.getImgPath(logo, storeId);
                        mchMap.put("logo", imgLogoUrl);
                        //店铺头像
                        String headImg = MapUtils.getString(mchUserInfo, "head_img");
                        mchMap.put("headimgurl", publicService.getImgPath(headImg, storeId));
                        //获取商户所属人信息
                        mchMap.put("user_name", MapUtils.getString(mchUserInfo, "user_name"));
                        mchMap.put("user_id", MapUtils.getString(mchUserInfo, "user_id"));
                        mchMap.put("source", MapUtils.getString(mchUserInfo, "source"));
                        mchMap.put("shop_id", MapUtils.getInteger(mchUserInfo, "id"));
                        mchMap.put("name", MapUtils.getString(mchUserInfo, "name"));
                        //宣传图
                        String mchBackImgUrl = publicService.getImgPath(MapUtils.getString(mchUserInfo, "poster_img"), storeId);
                        if (StringUtils.isEmpty(mchBackImgUrl)) {
                            MchConfigModel mchConfig = new MchConfigModel();
                            mchConfig.setStore_id(storeId);
                            mchConfig.setMch_id(customerModelMapper.getStoreMchId(storeId));
                            mchConfig = mchConfigModelMapper.selectOne(mchConfig);
                            if (mchConfig != null) {
                                mchBackImgUrl = publicService.getImgPath(mchConfig.getPoster_img(), storeId);
                            }
                        }
                        mchMap.put("backImgUrl", mchBackImgUrl);
                        //是否关注
                        boolean collectionStatus = false;
                        if (user != null) {
                            UserCollectionModel userCollectionModel = new UserCollectionModel();
                            userCollectionModel.setUser_id(user.getUser_id());
                            userCollectionModel.setMch_id(MapUtils.getInteger(mchUserInfo, "id"));
                            int i = userCollectionModelMapper.selectCount(userCollectionModel);
                            if (i > 0) {
                                collectionStatus = true;
                            }
                        }
                        mchMap.put("collection_status", collectionStatus);
                        mchStoreAllList.add(mchMap);
                    }
                }
            }
            //获取店铺图片
            String imgLogoUrl = publicService.getImgPath(configModel.getLogo1(), storeId);
            //查询轮播图,根据排序、轮播图id顺序排列
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", storeId);
            parmaMap.put("type_not", 4);
            parmaMap.put("mch_id", 0);
            parmaMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            List<Map<String, Object>> resultBannerModels = bannerModelMapper.selectDynamic(parmaMap);
            //获取轮播图完整路径
            for (Map<String, Object> map : resultBannerModels) {
                String bannerImgUrl = publicService.getImgPath(MapUtils.getString(map, "image"), storeId);
                map.put("image", bannerImgUrl);
                map.put("type", "switchTab");
            }
            //产品配置 是否显示下架商品
            List<Integer> GoodsStatus = new ArrayList<>();
            GoodsStatus.add(DictionaryConst.GoodsStatus.NEW_GROUNDING);
            ProductModel productModel = new ProductModel();
            productModel.setStore_id(storeId);
            productModel = productModelMapper.selectOne(productModel);
            if (productModel != null) {
                if (ProductConfigModel.DISPLAY_BEAN_GOODS.equals(productModel.getIs_open())) {
                    //显示已下架商品
                    GoodsStatus.add(DictionaryConst.GoodsStatus.OFFLINE_GROUNDING);
                }
            }
            //查询商品并分类显示返回JSON至小程序
            //首页分类数据缓存
            String proClassesKey = String.format(GloabConst.RedisHeaderKey.INDEX_CACHE_PRO_CLASSDATA_CONDITION_, storeId);
            Object proClassesVales = redisUtil.get(proClassesKey);
            List<ProductClassModel> productClassModels = null;
            if (proClassesVales == null) {
                productClassModels = productClassModelMapper.getProduct(storeId);
                redisUtil.set(proClassesKey, productClassModels, HOME_PAGE_CLASS_CACHE_TIME);
            } else {
                productClassModels = DataUtils.cast(proClassesVales);
            }
            //首页分类商品数据缓存
            String indexCacheCondition = String.format(GloabConst.RedisHeaderKey.INDEX_CACHE_CLASS_CONDITION_, storeId);
            Object indexData = redisUtil.get(indexCacheCondition);
            if (indexData == null) {
                if (productClassModels != null) {
                    for (ProductClassModel productClass : productClassModels) {
                        Map<String, Object> appMap = new HashMap<>(16);
                        //获取商品
                        Map<String, Object> parmaMap1 = new HashMap<>(16);
                        parmaMap1.put("store_id", storeId);
                        parmaMap1.put("GoodsStatus", GoodsStatus);
                        parmaMap1.put("cid", productClass.getCid());
                        parmaMap1.put("sort_sort", DataUtils.Sort.DESC.toString());
                        parmaMap1.put("page", 0);
                        parmaMap1.put("pageSize", 10);
                        //只展示首页的产品
                        parmaMap1.put("show_adr",DictionaryConst.GoodsShowAdr.GOODSSHOWADR_INDEX);
                        if (productModel != null && productModel.getIs_display_sell_put() == 0) {
                            //不展示已售罄的商品
                            parmaMap1.put("stockNum", "stockNum");
                        }
                        List<Map<String, Object>> productListModels = productListModelMapper.getProductList(parmaMap1);
                        //商品信息逻辑处理
                        List<Map<String, Object>> resultProductMap = getGoodsInfo(storeId, gradeRate, productListModels);
                        appMap.put("list", resultProductMap);
                        appMap.put("cid", productClass.getCid());
                        appMap.put("english_name", productClass.getEnglish_name());
                        appMap.put("pname", productClass.getPname());
                        appList.add(appMap);
                    }
                    //缓存 5分钟 更新一次
                    redisUtil.set(indexCacheCondition, appList, HOME_PAGE_CLASS_CACHE_TIME);
                }
            } else {
                appList = DataUtils.cast(indexData);
            }
            //获取首页活动信息
            List<Map<String, Object>> MarketingList = getMarketingList(storeId, gradeRate, user);
            //获取首页导航栏
            List<Map<String, Object>> navList = uiNavigationBarModelMapper.getNavigationInfo(storeId);
            for (int i = 0; i < navList.size(); i++) {
                Map<String, Object> map = navList.get(i);
                String appImg = publicService.getImgPath(map.get("image").toString(), storeId);
                String url = String.valueOf(map.get("url"));
                //是否不属于插件
                boolean isPlugin = true;
                PluginsModel plugins = new PluginsModel();
                if (url.contains("/pagesA/OrderBidding/StoreBidding") || url.contains("/pagesA/OrderBidding/OrderBidding")) {
                    //竞拍
                    plugins.setPlugin_code(DictionaryConst.Plugin.AUCTION);
                } else if (url.contains("/pagesA/shop/sign")) {
                    //签到
                    plugins.setPlugin_code(DictionaryConst.Plugin.SIGN);
                } else if (url.contains("/pagesA/group/group")) {
                    //拼团
                    plugins.setPlugin_code(DictionaryConst.Plugin.GOGROUP);
                } else if (url.contains("/pagesB/seckill/seckill")) {
                    //秒杀
                    plugins.setPlugin_code(DictionaryConst.Plugin.SECONDS);
                } else if (url.contains("/pagesC/preSale/goods/goods")) {
                    //预售
                    plugins.setPlugin_code(DictionaryConst.Plugin.PRESELL);
                } else if (url.contains("/pagesB/integral/integral")) {
                    //积分
                    plugins.setPlugin_code(DictionaryConst.Plugin.INTEGRAL);
                } else if (url.contains("/pagesA/shop/coupon")) {
                    //个人中心入口是否显示 优惠券入口特殊处理 36190
                    CouponConfigModel couponConfigModel = new CouponConfigModel();
                    couponConfigModel.setStore_id(storeId);
                    couponConfigModel.setMch_id(0);
                    couponConfigModel = couponConfigModelMapper.selectOne(couponConfigModel);
                    if (couponConfigModel != null) {
                        if (couponConfigModel.getIs_show().equals(DictionaryConst.WhetherMaven.WHETHER_OK)) {
                            plugins.setPlugin_code(DictionaryConst.Plugin.COUPON);
                        }
                    }
                } else if (url.contains("/pagesA/bargain/bargain")) {
                    //砍价
                    plugins.setPlugin_code(DictionaryConst.Plugin.BARGAIN);
                } else if (url.contains("/pagesB/home/mchList")) {
                    //店铺
                    plugins.setPlugin_code(DictionaryConst.Plugin.MCH);
                } else if (url.contains("/pagesB/userVip/memberCenter")) {
                    //会员
                    plugins.setPlugin_code(DictionaryConst.Plugin.MEMBER);
                } else if (url.contains("/pagesA/distribution/fxProduct")) {
                    //分销
                    plugins.setPlugin_code(DictionaryConst.Plugin.DISTRIBUTION);
                } else {
                    //不是插件
                    isPlugin = false;
                }
                if (isPlugin && !DictionaryConst.Plugin.COUPON.equals(plugins.getPlugin_code())) {
                    if (!publicService.frontPlugin(storeId, plugins.getPlugin_code(), new HashMap<>(16))) {
                        //如果插件不存在则不显示该导航栏
                        navList.remove(i);
                        i--;
                    }
                }
                if (!isPlugin && MapUtils.getInteger(map, "isshow").equals(DictionaryConst.WhetherMaven.WHETHER_NO)) {
                    //如果不是插件则判断是否显示
                    navList.remove(i);
                    i--;
                }
                // 设置插件是否需要登录
                Integer flag = MapUtils.getInteger(map, "is_login");
                boolean is_login = DictionaryConst.WhetherMaven.WHETHER_OK == flag;
                map.put("is_login", is_login);
                map.put("appimg", appImg);
                map.put("isPlugin", isPlugin);
            }
            //会员插件是否开启
            boolean memberPlugin = false;
            //会员提醒
            boolean remind = false;
            Map<String, Object> config = memberConfigMapper.getConfig(storeId);
            if (MapUtils.getInteger(config, "id") != null && MapUtils.getInteger(config, "is_open") > 0) {
                memberPlugin = true;
                if (user != null && StringUtils.isNotEmpty(user.getUser_id())) {
                    if (Integer.parseInt(user.getIs_box()) == DictionaryConst.WhetherMaven.WHETHER_OK && user.getGrade().equals(User.MEMBER)) {
                        if (config != null && MapUtils.getInteger(config, "is_open") > 0) {
                            Integer renewOpen = MapUtils.getInteger(config, "renew_open");
                            if (renewOpen.equals(DictionaryConst.WhetherMaven.WHETHER_OK)) {
                                if (user.getGrade_end() != null) {
                                    Integer renewDay = MapUtils.getInteger(config, "renew_day");
                                    long end = user.getGrade_end().getTime() / 1000;
                                    long now = new Date().getTime() / 1000;
                                    int betweenDate = DateUtil.getBetweenDate(now, end);
                                    if (betweenDate < renewDay) {
                                        remind = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //TODO 会员插件开关状态(diy组件可以添加就删除此逻辑)
            resultMap.put("memberPlugin", memberPlugin);
            //店铺图片
            resultMap.put("logo", imgLogoUrl);
            //消息数量
            resultMap.put("xxnum", messageNum);
            //地理位置
            resultMap.put("region", currentMap);
            //轮播图
            resultMap.put("banner", resultBannerModels);
            //导航栏图标
            resultMap.put("nav_list", navList);
            //获取签到标识 is_sign_status、sign_status
//            resultMap.putAll(publicService.sign(user));
            //附近店铺
            resultMap.put("r_mch", mchStoreAllList);
            //会员等级
            resultMap.put("grade", isGradeRate);
            //会员提醒
            resultMap.put("grade_remind", remind);
            //是否登陆 0未登录
            resultMap.put("login_status", islogin);
            //商城活动商品列表
            resultMap.put("Marketing_list", MarketingList);
            //查询商品并分类显示返回JSON至小程序
            resultMap.put("list2", appList);
            //获取满减活动图片列表
//            resultMap.put("subtraction_list", publiceSubtractionService.getSubtractionImage(storeId));
            //TODO 暂时不用这个满减
            resultMap.put("subtraction_list", new ArrayList<>());
            //获取分销商品信息
            resultMap.put("distribution_list", publiceDistributionService.getGoodsInfo(storeId, user, new PageModel(0, 3)));
            //首页标题
            resultMap.put("appTitle", configModel.getApp_title());
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("首页接口出错 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "index");
        }

        return resultMap;
    }

    /**
     * 首页营销市场
     */
    String HOME_MARKET_LIST_KEY = "home_index_store_";

    /**
     * 获取商城首页活动数据
     *
     * @param storeId   -
     * @param gradeRate - 当前会员折扣
     * @return List
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2021/2/22 12:13
     */
    private List<Map<String, Object>> getMarketingList(int storeId, BigDecimal gradeRate, User user) throws LaiKeAPIException {
        List<Map<String, Object>> resultList = null;
        try {
            //默认获取自营店id
            Integer storeMchId = customerModelMapper.getStoreMchId(storeId);
            //获取商城活动列表
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", storeId);
            parmaMap.put("is_display", 1);
            parmaMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            String homeMarketListKey = HOME_MARKET_LIST_KEY + storeId;
            String data = (String) redisUtil.get(homeMarketListKey);

            if (!StringUtils.isEmpty(data)) {
                resultList = JSON.parseObject(data, new TypeReference<List<Map<String, Object>>>() {
                });
            }

            if (resultList != null && resultList.size() > 0) {
                return resultList;
            }

            resultList = new ArrayList<>();
            List<Map<String, Object>> activityModelList = activityModelMapper.selectDynamic(parmaMap);
            if (activityModelList != null) {
                //获取
                tag:
                for (Map<String, Object> activityMap : activityModelList) {
                    List<Map<String, Object>> goodsList = null;
                    //活动类型
                    int acType = Integer.parseInt(activityMap.get("plug_type").toString());
                    //活动id
                    int id = Integer.parseInt(activityMap.get("id").toString());
                    if (acType == ActivityModel.ACTIVITY_TYPE_SPECIAL) {
                        //获取正在活动的商品
                        List<Integer> goodsStatusList = publicGoodsService.getProductSettings(storeId);
                        goodsList = activityProModelMapper.getActivityGoodsList(storeId, id, goodsStatusList);
                        if (goodsList != null) {
                            for (Map<String, Object> map : goodsList) {
                                int goodsId = Integer.parseInt(map.get("id").toString());
                                List<String> sType = null;
                                String goodsType = map.get("s_type") + "";
                                if (StringUtils.isEmpty(goodsType)) {
                                    sType = DataUtils.convertToList(map.get("s_type").toString().split(","));
                                }
                                //会员价
                                BigDecimal vipPrice = new BigDecimal(map.get("price").toString());
                                vipPrice = vipPrice.multiply(gradeRate);
                                //商品图片
                                String imageUrl = publicService.getImgPath(map.get("imgurl").toString(), storeId);
                                map.put("imgurl", imageUrl);
                                //产品主图
                                imageUrl = publicService.getImgPath(map.get("cover_map").toString(), storeId);
                                map.put("cover_map", imageUrl);
                                //获取库存数量
                                int stockNum = confiGureModelMapper.countConfigGureNum(goodsId);
                                map.put("num", stockNum);

                                //新品、热销、推荐标识
                                boolean xp = false, rx = false, tj = false;
                                if (sType != null) {
                                    if (sType.contains(DictionaryConst.LKT_SPLX_001)) {
                                        xp = true;
                                    } else if (sType.contains(DictionaryConst.LKT_SPLX_002)) {
                                        rx = true;
                                    } else if (sType.contains(DictionaryConst.LKT_SPLX_003)) {
                                        tj = true;
                                    }
                                }
                                map.put("xp", xp);
                                map.put("rx", rx);
                                map.put("tj", tj);
                                map.put("vip_price", vipPrice);
                            }
                        }
                    } else {
                        //营销插件
                        switch (acType) {
                            case 2:
                                //拼团
//                                goodsList = publiceGroupService.getGroupGoodsInfo(storeId, 0, 3);
                                break;
                            case 3:
                                //砍价
//                                goodsList = publiceBargainService.bargainGoodsInfo(storeId, 0, 10, user);
                                break;
                            case 4:
                                //竞拍
                                goodsList = publiceAuctionService.getAuctionGoodsInfo(storeId, user, 0, 3);
                                break;
                            case 7:
                                //积分商城
                                IntegralConfigModel integralConfigModel = new IntegralConfigModel();
                                integralConfigModel.setStore_id(storeId);
                                integralConfigModel.setMch_id(storeMchId);
                                integralConfigModel = integralConfigModelMapper.selectOne(integralConfigModel);
                                if (integralConfigModel != null) {
                                    if (integralConfigModel.getStatus().equals(0)) {
                                        continue tag;
                                    }
                                } else {
                                    continue tag;
                                }
                                goodsList = publiceIntegralService.getIntegralGoodsInfo(storeId, 0, 3);
                                break;
                            case 8:
                                //秒杀
//                                Integer zyMchId = customerModelMapper.getStoreMchId(storeId);
//                                goodsList = this.seconds(storeId, zyMchId);
                                break;
                            default:
                                break;
                        }
                    }
                    if (goodsList == null) {
                        goodsList = new ArrayList<>();
                    }
                    activityMap.put("list", goodsList);
                    activityMap.put("title", MapUtils.getString(activityMap, "name"));
                    resultList.add(activityMap);
                }
                redisUtil.set(homeMarketListKey, JSON.toJSONString(resultList), 300);
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取商城首页活动数据", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "getMarketingList");
        }
        return resultList;
    }


    @DubboApiMethod(apiKey = "com.laike.app.get_more",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public List<Map<String, Object>> getMore(MainVo vo, int cid) throws LaiKeAPIException {
        try {
            //商品状态 用于in查询
            List<Integer> GoodsStatus = new ArrayList<>();
            //商品集
            List<Map<String, Object>> resultProductMap;


            //获取用户信息
            User user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, false);
            //会员折扣率
            BigDecimal gradeRate = getMemberGrade(vo.getStoreId(), user);

            //获取商户产品配置
            ProductConfigModel productConfigModel = new ProductConfigModel();
            productConfigModel.setStore_id(vo.getStoreId());
            productConfigModel = productConfigModelMapper.selectOne(productConfigModel);
            //已上架
            GoodsStatus.add(DictionaryConst.GoodsStatus.NEW_GROUNDING);
            if (productConfigModel != null && productConfigModel.getIs_open() != 0) {
                //已下架
                GoodsStatus.add(DictionaryConst.GoodsStatus.OFFLINE_GROUNDING);
            }
            //根据条件获取商品列表
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("GoodsStatus", GoodsStatus);
            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("cid", cid);
            parmaMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("show_adr",DictionaryConst.GoodsShowAdr.GOODSSHOWADR_INDEX);
            parmaMap.put("page", vo.getPageNo());
            parmaMap.put("pageSize", vo.getPageSize());
            List<Map<String, Object>> productListModels = productListModelMapper.getProductList(parmaMap);
            resultProductMap = getGoodsInfo(vo.getStoreId(), gradeRate, productListModels);

            return resultProductMap;
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("更多商品加载失败", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_GDSPJZSBWLYC, "更多商品加载失败,网络异常", "getMore");
        }

    }

    String HOME_MEMBER_GRADE_KEY = "home_member_grade_key_";

    /**
     * 获取会员等级信息
     * 用户登录了，则直接去数据获取
     * 用户没有登录则从缓存获取没有再从数据库查询获取
     *
     * @param storeId
     * @param user
     * @return
     */
    private BigDecimal getMemberGrade(int storeId, User user) {
        //
        if (user != null) {
            return BigDecimal.valueOf(publicMemberService.getMemberGradeRate(null, user.getUser_id(), storeId));
        }

        String memberGardeKey = HOME_MEMBER_GRADE_KEY + storeId;
        caffeineCache.getIfPresent(memberGardeKey);
        Object gradeCache = caffeineCache.asMap().get(memberGardeKey);
        if (gradeCache == null) {
            gradeCache = userGradeModelMapper.getGradeLow(storeId).divide(new BigDecimal("10"), 2, BigDecimal.ROUND_HALF_UP);
            caffeineCache.put(memberGardeKey, gradeCache);
        }
        return new BigDecimal(String.valueOf(gradeCache));
    }


    @DubboApiMethod(apiKey = "com.laike.app.get_location",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public Map<String, Object> getLocation(MainVo vo, Integer groupId) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        //排序后的结果集  按照每个市首字母进行键位排序
        Map<String, List<Map<String, Object>>> adminCgMap = new TreeMap<>(Comparator.naturalOrder());
        //获取县
        List<Map<String, Object>> adminCgModelList = new ArrayList<>();
        try {
            //获取市区
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("G_Level", DictionaryConst.Position.LEVEL_3);
            List<Map<String, Object>> adminCgModels = adminCgModelMapper.getAdminCgInfoDynamic(parmaMap);
            for (Map<String, Object> adminCg : adminCgModels) {
                String cgName = adminCg.get("G_CName").toString();
                //处理市辖区
                if ("市辖区".equals(cgName)) {
                    int pid = Integer.parseInt(adminCg.get("G_ParentID").toString());
                    AdminCgModel adminCgModel = new AdminCgModel();
                    adminCgModel.setGroupID(pid);
                    adminCgModel = adminCgModelMapper.selectOne(adminCgModel);
                    if (adminCgModel != null) {
                        cgName = adminCgModel.getG_CName();
                        adminCg.put("G_CName", cgName);
                    } else {
                        logger.debug("未获取到市辖区 G_ParentID :" + cgName);
                    }
                }
                //获取市名称每个字拼音首字母
                String ypHead = PinyinUtils.getPinYinHeadChar(cgName);
                //截取第一个
                String first = ypHead.substring(0, 1).toUpperCase();
                List<Map<String, Object>> adminCgModelListTemp = new ArrayList<>();
                if (adminCgMap.containsKey(first)) {
                    adminCgModelListTemp = adminCgMap.get(first);
                }
                adminCgModelListTemp.add(adminCg);
                adminCgMap.put(first, adminCgModelListTemp);
            }
            //获取县级
            if (groupId != null) {
                parmaMap.clear();
                parmaMap.put("G_ParentID", groupId);
                adminCgModelList = adminCgModelMapper.getAdminCgInfoDynamic(parmaMap);
            }

        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("位置获取失败", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WZHQSBWLYC, "位置获取失败,网络异常", "getLocation");
        }
        resultMap.put("list", adminCgMap);
        resultMap.put("xian", adminCgModelList);
        return resultMap;
    }


    @DubboApiMethod(apiKey = "com.laike.app.guided_graph",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public List<GuideModel> guidedGraph(int storeId, String accessId, String language, int storeType) throws LaiKeAPIException {
        List<GuideModel> guideModelList;
        try {
            GuideModel guideModel = new GuideModel();
            guideModel.setStore_id(storeId);
            guideModel.setSource(storeType);
            guideModel.setType(DictionaryConst.GuideType.GUIDETYPE_00);
            guideModelList = guideModelMapper.getGuidedGraph(guideModel);
            for (GuideModel guide : guideModelList) {
                String imgUrl = guide.getImage();
                imgUrl = publicService.getImgPath(imgUrl, storeId);
                guide.setImage(imgUrl);
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("开机图获取失败", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "guidedGraph");
        }

        return guideModelList;
    }

    /**
     * 新品上市数据
     */
    String HOME_INDEX_NEWARRIVAL_KEY = "home_app_index_new_arrival_";

    @DubboApiMethod(apiKey = "com.laike.app.new_arrival",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public Map<String, Object> newArrival(MainVo vo) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        //当前登录会员享受的折扣
        BigDecimal gradeRate = BigDecimal.ONE;
        //只有登录才享受折扣值
        BigDecimal gradeValue = BigDecimal.ZERO;
        //商品信息
        List<Map<String, Object>> goodsList;
        //是否享受会员折扣
        boolean isGrade = false;
        try {
            User user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, false);
            //商品状态 用于in查询
            List<Integer> goodsStatus = new ArrayList<>();
            Map<String, Object> parmaMap = new HashMap<>(16);
            gradeRate = getMemberGrade(vo.getStoreId(), user);
            gradeValue = gradeRate;
            //获取折扣
            if (user != null) {
                if (BigDecimal.ONE.compareTo(gradeRate) > 0) {
                    isGrade = true;
                }
            }

            //获取商户产品配置
            ProductConfigModel productConfigModel = new ProductConfigModel();
            productConfigModel.setStore_id(vo.getStoreId());
            productConfigModel = productConfigModelMapper.selectOne(productConfigModel);
            //已上架
            goodsStatus.add(DictionaryConst.GoodsStatus.NEW_GROUNDING);
            if (productConfigModel != null && productConfigModel.getIs_open() != 0) {
                //已下架
                goodsStatus.add(DictionaryConst.GoodsStatus.OFFLINE_GROUNDING);
            }
            if (productConfigModel != null && productConfigModel.getIs_display_sell_put() == 0) {
                //不展示已售罄的商品
                parmaMap.put("stockNum", "stockNum");
            }


            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("GoodsStatus", goodsStatus);

            //商品标签
            int proId = proLabelModelMapper.getProLabelNew(vo.getStoreId());
            parmaMap.put("s_type", proId);
            parmaMap.put("else_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("pageNo", vo.getPageNo());
            parmaMap.put("pageSize", vo.getPageSize());

            String appIndexArrivalKey = HOME_INDEX_NEWARRIVAL_KEY + vo.getStoreId();
            caffeineCache.getIfPresent(appIndexArrivalKey);
            goodsList = (List<Map<String, Object>>) caffeineCache.asMap().get(appIndexArrivalKey);

            if (goodsList == null || goodsList.size() == 0 || vo.getPageSize() >= 10) {
                goodsList = productListModelMapper.getProductListDynamic(parmaMap);
                for (Map<String, Object> map : goodsList) {
                    String imgUrl = map.get("imgurl") + "";
                    imgUrl = publicService.getImgPath(imgUrl, vo.getStoreId());
                    map.put("imgurl", imgUrl);
                    //获取商品标签
                    String sType = MapUtils.getString(map, "s_type");
                    map.put("s_type_list", publicGoodsService.getGoodsLabelList(vo.getStoreId(), DataUtils.convertToList(StringUtils.trim(sType, SplitUtils.DH).split(SplitUtils.DH))));

                }
                GoodsDataUtils.getGoodsInfo(goodsList, gradeRate);
                caffeineCache.put(appIndexArrivalKey, goodsList);
            }

        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("新品上市获取失败", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "newArrival");
        }
        resultMap.put("list", goodsList);
        resultMap.put("grade", gradeValue);
        resultMap.put("isGrade", isGrade);
        return resultMap;
    }

    @DubboApiMethod(apiKey = "com.laike.app.recommend_stores",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    
    @Override
    public Map<String, Object> recommendStores(MainVo vo, String longitude, String latitude, Integer cid) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            List<Map<String, Object>> mchMapList = new ArrayList<>();
            //38558禅道优化
            Map<String, Object> paramMap = new HashMap<>(16);
            paramMap.put("store_id", vo.getStoreId());
            paramMap.put("recovery", DictionaryConst.ProductRecycle.NOT_STATUS);
            paramMap.put("review_status", DictionaryConst.ExameStatus.EXAME_PASS_STATUS);
            paramMap.put("is_lock", String.valueOf(DictionaryConst.WhetherMaven.WHETHER_NO));
            paramMap.put("collection_num_sort", DataUtils.Sort.DESC.toString());
            paramMap.put("add_time_sort", DataUtils.Sort.DESC.toString());
            if (cid != null){
                paramMap.put("cid", cid);
            }
            List<Map<String, Object>> mchUserInfos = mchModelMapper.getMchUserInfo(paramMap);
            if (mchUserInfos != null && mchUserInfos.size() > 0){
                for (Map<String, Object> mchUserInfo : mchUserInfos){
                    Map<String, Object> mchMap = new HashMap<>(16);
                    //获取商户logo图片地址
                    String logo = MapUtils.getString(mchUserInfo, "logo");
                    String imgLogoUrl = publicService.getImgPath(logo, vo.getStoreId());
                    mchMap.put("logo", imgLogoUrl);
                    //店铺头像
                    String headImg = MapUtils.getString(mchUserInfo, "head_img");
                    mchMap.put("headimgurl", publicService.getImgPath(headImg, vo.getStoreId()));
                    //获取商户所属人信息
                    mchMap.put("user_name", MapUtils.getString(mchUserInfo, "user_name"));
                    mchMap.put("user_id", MapUtils.getString(mchUserInfo, "user_id"));
                    mchMap.put("source", MapUtils.getString(mchUserInfo, "source"));
                    mchMap.put("shop_id", MapUtils.getInteger(mchUserInfo, "id"));
                    mchMap.put("name", MapUtils.getString(mchUserInfo, "name"));
                    //宣传图
                    String mchBackImgUrl = publicService.getImgPath(MapUtils.getString(mchUserInfo, "poster_img"), vo.getStoreId());
                    if (StringUtils.isEmpty(mchBackImgUrl)) {
                        MchConfigModel mchConfig = new MchConfigModel();
                        mchConfig.setStore_id(vo.getStoreId());
                        mchConfig.setMch_id(customerModelMapper.getStoreMchId(vo.getStoreId()));
                        mchConfig = mchConfigModelMapper.selectOne(mchConfig);
                        if (mchConfig != null) {
                            mchBackImgUrl = publicService.getImgPath(mchConfig.getPoster_img(), vo.getStoreId());
                        }
                    }
                    mchMap.put("backImgUrl", mchBackImgUrl);
                    mchMap.put("shop_information", MapUtils.getString(mchUserInfo, "shop_information"));
                    mchMap.putAll(publicService.commodityInformation(vo.getStoreId(), MapUtils.getInteger(mchUserInfo, "id")));
                    mchMapList.add(mchMap);
                }
            }
            resultMap.put("list", mchMapList);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("推荐门店获取失败", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "recommendStores");
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> mchClass(MainVo vo) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            Map<String, Object> paramMap = new HashMap<>(16);
            paramMap.put("storeId", vo.getStoreId());
            paramMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            paramMap.put("isDisplay", DictionaryConst.WhetherMaven.WHETHER_OK);
            int i = mchClassModelMapper.countCondition(paramMap);
            List<Map<String, Object>> list = new ArrayList<>();
            if (i > 0) {
                list = mchClassModelMapper.selectCondition(paramMap);
                list.stream().forEach(map -> {
                    map.put("img", publicService.getImgPath(MapUtils.getString(map, "img"), vo.getStoreId()));
                    map.put("add_date", DateUtil.dateFormate(MapUtils.getString(map, "add_date"), GloabConst.TimePattern.YMDHMS));
                });
            }
            resultMap.put("total", i);
            resultMap.put("list", list);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取店铺分类列表 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "mchClassList");
        }
        return resultMap;
    }


    @DubboApiMethod(apiKey = "com.laike.app.select_language",
            login = false, module = AppConst.MODULE_NAME, version = "1.0.0")
    @Override
    public boolean selectLanguage(int storeId, String accessId, String language) throws LaiKeAPIException {
        boolean result = false;
        try {
            User user = null;
            if (!StringUtils.isEmpty(accessId)) {
                //获取用户信息
                Object obj = redisUtil.get(GloabConst.RedisHeaderKey.LOGIN_ACCESS_TOKEN + accessId);
                if (obj != null) {
                    user = JSON.parseObject(obj.toString(), User.class);
                    Map<String, Object> parmaMap = new HashMap<>(16);
                    parmaMap.put("store_id", storeId);
                    parmaMap.put("access_id", user.getAccess_id());
                    parmaMap.put("language", language);
                    int count = userBaseMapper.updateUserAccessId(parmaMap);
                    if (count < 1) {
                        logger.debug("用户修改语言失败 userid=" + user.getUser_id());
                    } else {
                        result = true;
                    }
                }
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("更改语言异常" + e.getMessage());
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "selectLanguage");
        }

        return result;
    }

    //首页推荐和上新缓存数据
    String HOME_RECOMMONED_PROS_KEY = "home_recommoned_pros_info_";
    //商品配置信息
    String PRO_CONFIG_INFO_KEY = "pro_config_info_key_";

    @Override
    public Map<String, Object> recommend(MainVo vo) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        List<Map<String, Object>> goodsList;
        BigDecimal grade = BigDecimal.ZERO;
        BigDecimal gradeRate = BigDecimal.ONE;
        List<Integer> goodsStatus = new ArrayList<>();
        ProductConfigModel productConfigModel = null;
        //是否享受会员折扣
        boolean isGrade = false;
        try {
            User user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, false);
            //获取商户产品配置
            String proConfigInfoKey = PRO_CONFIG_INFO_KEY + vo.getStoreId();
            caffeineCache.getIfPresent(proConfigInfoKey);
            productConfigModel = (ProductConfigModel) caffeineCache.asMap().get(proConfigInfoKey);
            if (productConfigModel == null) {
                productConfigModel = new ProductConfigModel();
                productConfigModel.setStore_id(vo.getStoreId());
                productConfigModel = productConfigModelMapper.selectOne(productConfigModel);
                if (productConfigModel != null) {
                    caffeineCache.put(proConfigInfoKey, productConfigModel);
                }
            }

            //已上架
            goodsStatus.add(DictionaryConst.GoodsStatus.NEW_GROUNDING);
            if (productConfigModel != null && productConfigModel.getIs_open() != 0) {
                //已下架
                goodsStatus.add(DictionaryConst.GoodsStatus.OFFLINE_GROUNDING);
            }

            gradeRate = getMemberGrade(vo.getStoreId(), user);
            //获取用户信息
            if (!StringUtils.isEmpty(vo.getAccessId())) {
                //获取用户信息
                user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil);
                if (user != null) {
                    grade = new BigDecimal(user.getGrade());
//                    gradeRate = BigDecimal.valueOf(publicMemberService.getMemberGradeRate(null, user.getUser_id(), vo.getStoreId()));
                    if (BigDecimal.ONE.compareTo(gradeRate) > 0) {
                        isGrade = true;
                    }
                }
            }


            //获取匹配到的推荐商品
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("GoodsStatus", goodsStatus);
            parmaMap.put("else_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("s_type", proLabelModelMapper.getProLabelTop(vo.getStoreId()));
            parmaMap.put("sTypeNotNull", "sTypeNotNull");
            if (productConfigModel != null && productConfigModel.getIs_display_sell_put() == 0) {
                //不展示已售罄的商品
                parmaMap.put("stockNum", "stockNum");
            }
            parmaMap.put("pageNo", vo.getPageNo());
            parmaMap.put("pageSize", vo.getPageSize());


            String homeRecommonedProInfosKey = HOME_RECOMMONED_PROS_KEY + vo.getStoreId();
            goodsList = (List<Map<String, Object>>) caffeineCache.asMap().get(homeRecommonedProInfosKey);
            if (goodsList == null || goodsList.size() == 0 || vo.getPageSize() >= 10) {
                goodsList = productListModelMapper.getProductListDynamic(parmaMap);
                //处理商品信息
                for (Map<String, Object> map : goodsList) {
                    String imgUrl = map.get("imgurl") + "";
                    imgUrl = publicService.getImgPath(imgUrl, vo.getStoreId());
                    map.put("imgurl", imgUrl);//获取商品标签
                    String sType = MapUtils.getString(map, "s_type");
                    map.put("s_type_list", publicGoodsService.getGoodsLabelList(vo.getStoreId(), DataUtils.convertToList(com.laiketui.common.utils.tool.str.StringUtils.trim(sType, SplitUtils.DH).split(SplitUtils.DH))));
                }
                GoodsDataUtils.getGoodsInfo(goodsList, gradeRate);
                caffeineCache.put(homeRecommonedProInfosKey, goodsList);
            }

            resultMap.put("list", goodsList);
            resultMap.put("grade", grade);
            resultMap.put("isGrade", isGrade);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("推荐商品异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "recommend");
        }
        return resultMap;
    }

    /**
     * 获取商品信息
     *
     * @param productListModels -
     * @return List
     * @throws LaiKeAPIException -
     */
    private List<Map<String, Object>> getGoodsInfo(Integer storeId, BigDecimal grade_rate, List<Map<String, Object>> productListModels) throws LaiKeAPIException {
        List<Map<String, Object>> resultMap = new ArrayList<>();
        try {
            //商品信息逻辑处理
            for (Map<String, Object> map : productListModels) {
                int pid = Integer.parseInt(map.get("id") + "");
                //销量
                int volume = Integer.parseInt(map.get("volume") + "");
                //真实销量
                int realVolume = Integer.parseInt(map.get("real_volume") + "");
                //产品值属性 1：新品,2：热销，3：推荐
                String stype = map.get("s_type") + "";
                //图片url
                String image = map.get("imgurl") + "";
                //获取商品标签
                map.put("s_type_list", publicGoodsService.getGoodsLabelList(storeId, DataUtils.convertToList(StringUtils.trim(stype, SplitUtils.DH).split(SplitUtils.DH))));
                if (volume < 0) {
                    volume = 0;
                }
                //判断会员等级 等级不同，优惠不同`
                //原来价格
                BigDecimal vipYprice = new BigDecimal(map.get("price") + "");
                //打折后的价格 折扣 原来价格 * 折扣  = 优惠价
                BigDecimal vipPrice = vipYprice.multiply(grade_rate);
                if (grade_rate.compareTo(new BigDecimal("1")) > 0) {
                    vipPrice = vipPrice.divide(new BigDecimal("10"), 2, BigDecimal.ROUND_HALF_UP);
                }
                //获取轮播图完整路径
                String imagUrl = publicService.getImgPath(image, storeId);
                //商品封面图
                String coverUrl = publicService.getImgPath(String.valueOf(map.get("cover_map")), storeId);
                //店铺logo
                String logoUrl = publicService.getImgPath(String.valueOf(map.get("logo")), storeId);
                //库存
                int countNum = confiGureModelMapper.countConfigGureNum(pid);
                map.put("vip_yprice", vipYprice);
                map.put("vip_price", vipPrice);
                map.put("imgurl", imagUrl);
                map.put("logo", logoUrl);
                map.put("cover_map", coverUrl);
                map.put("contNum", countNum);
                map.put("volume", volume + realVolume);
                //付款人数   禅道46291
                int payPeople = orderDetailsModelMapper.payPeople(storeId, pid);
                map.put("payPeople", payPeople);
                resultMap.add(map);
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("首页加载商品 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_HQSPXXSB, "获取商品信息失败", "getGoodsInfo");
        }
        return resultMap;
    }

    /**
     * 获取秒杀商品
     *
     * @param storeId -
     * @param mchId   -
     * @return List
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2020/10/14 12:52
     */
    private List<Map<String, Object>> seconds(int storeId, Integer mchId) throws LaiKeAPIException {
        List<Map<String, Object>> groupProductModels = new ArrayList<>();
        try {
            //获取秒杀配置
            SecondsConfigModel secondsConfigModel = new SecondsConfigModel();
            secondsConfigModel.setStore_id(storeId);
            if (mchId != null) {
                secondsConfigModel.setMch_id(mchId);
            }
            secondsConfigModel = secondsConfigModelMapper.selectOne(secondsConfigModel);
            //判断秒杀是否开启
            if (secondsConfigModel.getIs_open() != 1) {
                return groupProductModels;
            }

            //当前时间年月日
            String sysdate = FastDateFormat.getInstance("yyyy-MM-dd").format(new Date());
            //获取当前时段
            GregorianCalendar calendar = new GregorianCalendar();
            String hour = calendar.get(Calendar.HOUR_OF_DAY) + "";
            //时段 S:1970-01-01 00:00:00 E:1970-01-01 01:00:00
            //获取当前正在进行的秒杀活动
            Map<String, String> parmaMap = new HashMap<>(16);
            parmaMap.put("date", "1970-01-01 " + hour + ":00:00");
            parmaMap.put("time", sysdate);
            List<Map<String, Object>> currentSecList = secondsProModelMapper.getCurrentSeconds(parmaMap);
            if (currentSecList != null && currentSecList.size() > 0) {
                for (Map<String, Object> map : currentSecList) {
                    //商品名称
                    String goodsName = map.get("product_title").toString();
                    int pid = (int) map.get("pro_id");

                    //获取商品信息
                    ConfiGureModel confiGureModel = new ConfiGureModel();
                    confiGureModel.setId(pid);
                    confiGureModel = confiGureModelMapper.selectOne(confiGureModel);
                    String goodsImgUrl = publicService.getImgPath(confiGureModel.getImg(), storeId);
                    BigDecimal goodsPrice = confiGureModel.getPrice();
                    map.put("imgurl", goodsImgUrl);
                    map.put("product_title", goodsName);
                    map.put("price", goodsPrice.floatValue());

                    groupProductModels.add(map);
                }
            }


        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            e.printStackTrace();
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_SYMSHQSBWLYC, "首页秒杀获取失败,网络异常", "seconds");
        }

        return groupProductModels;
    }

    /**
     * 拼团流程
     *
     * @param storeId -
     * @return List
     * @throws LaiKeAPIException -
     * @author Trick
     * @date 2020/10/13 13:26
     */
    private List<Map<String, Object>> goGroup(int storeId) throws LaiKeAPIException {
        List<Map<String, Object>> groupProductModels = new ArrayList<>();
        int paegr = 1;
        int start = (paegr - 1) * 10;
        int end = paegr * 10;

        try {
            //获取拼团商品
            Map<String, Object> parmaMap = new HashMap<>();
            parmaMap.put("store_id", storeId);
            parmaMap.put("group_activity_no", "");
            parmaMap.put("g_status", GroupProductModel.GROUP_GOODS_STATUS_UNDER_WAY);
            parmaMap.put("pageStart", start);
            parmaMap.put("pageEnd", end);
            List<Map<String, Object>> groupProductModelList = groupProductModelMapper.getGroupProductAll(parmaMap);

            //判断是否有拼团商品
            if (groupProductModelList != null && !groupProductModelList.isEmpty()) {
                for (Map<String, Object> map : groupProductModelList) {
                    //规格id
                    String attrId = map.get("attr_id").toString();
                    //审核状态
                    int auditStatus = Integer.parseInt(map.get("audit_status") + "");
                    //产品id
                    int productId = Integer.parseInt(map.get("product_id") + "");
                    //活动参数序列化对象
                    String productData = map.get("group_data") + "";
                    //折扣参数序列化对象
                    String groupLevelStr = map.get("group_level") + "";
                    //平台活动id
                    int platformActivitiesId = Integer.parseInt(map.get("platform_activities_id") + "");

                    //产品最低价格
                    BigDecimal marketPrice;


                    //判断拼团产品是否审核通过
                    if (auditStatus == (Integer.parseInt(DictionaryConst.ExameStatus.EXAME_PASS_STATUS))) {
                        //查询活动库存
                        parmaMap = new HashMap<>(16);
                        parmaMap.put("store_id", storeId);
                        parmaMap.put("product_id", productId);
                        int groupNum = groupProductModelMapper.getGroupProductNum(parmaMap);
                        //所需产品数量
                        int needNum = 0;
                        //活动时间
                        StdClass stdClass = SerializePhpUtils.getUnserializeObj(productData, StdClass.class);

                        //判断活动是否结束
                        long sysdate = System.currentTimeMillis();
                        String imgUrl = publicService.getImgPath(map.get("imageurl") + "", storeId);

                        //拼团折扣
                        BigDecimal zhekou = new BigDecimal("0");
                        //参团人数
                        int groupnum = 0;
                        //获取折扣 折扣有多层 a:2:{i:2;s:5:"80~70";i:3;s:5:"70~60";}   {2=80~70, 3=70~60}
                        Map groupLevel = SerializePhpUtils.getUnserializeObj(groupLevelStr, HashMap.class);
                        //取一层参数
                        assert groupLevel != null;
                        //{2=80~70} key表示几人团 第一个参数表示参团折扣 第二个参数表示开团折扣
                        for (Object key : groupLevel.keySet()) {
                            //获取开团折扣
                            String[] zhekous = (groupLevel.get(key) + "").split("~");
                            zhekou = zhekou.add(new BigDecimal(zhekous[1]));
                            //获取参团人数
                            groupnum = (int) key;
                            break;
                        }
                        //查询属性里最高的金额
                        marketPrice = confiGureModelMapper.getProductMaxPrice(productId);
                        BigDecimal kaiPrice = marketPrice.multiply(zhekou).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);

                        //设置时间 初始值
                        assert stdClass != null;
                        long stime = stdClass.getStarttime().getTime();
                        long leftTime = stime > sysdate ? (stime - sysdate) : 0;
                        map.put("leftTime", leftTime);
                        //拼团产品图片
                        map.put("hour", "00");
                        //活动状态
                        map.put("mniuate", "00");
                        //活动状态
                        map.put("second", "00");

                        //查询活动商品最低价格
                        BigDecimal activityMinPrice = new BigDecimal("0");
                        ConfiGureModel confiGureModel = new ConfiGureModel();
                        confiGureModel.setPid(productId);
                        if (platformActivitiesId > 0) {
                            //加规格
                            confiGureModel.setId(Integer.parseInt(attrId));
                            activityMinPrice = confiGureModelMapper.getActivityGoodsLowPriceByAttrId(confiGureModel);
                        } else {
                            activityMinPrice = confiGureModelMapper.getActivityGoodsLowPrice(confiGureModel);
                        }

                        //查询最低价格和拼团人数
                        //最低价格
                        BigDecimal minBili = new BigDecimal("100000000");
                        //最低人数
                        BigDecimal minMan = new BigDecimal("999999");
                        for (Object key : groupLevel.keySet()) {
                            String[] parma = (groupLevel.get(key) + "").split(",");
                            int tempZheKou = Integer.parseInt(parma[0]);
                            if (minBili.intValue() > tempZheKou) {
                                minBili = new BigDecimal(tempZheKou + "");
                                minMan = new BigDecimal(key.toString());
                            }
                        }
                        BigDecimal minPrice = new BigDecimal(activityMinPrice + "");
                        minPrice = minPrice.multiply(minBili).divide(new BigDecimal("100"), 2, BigDecimal.ROUND_HALF_UP);


                        //所需产品数量
                        map.put("sum", needNum);
                        //拼团产品图片
                        map.put("imageurl", imgUrl);
                        //活动数量
                        map.put("num", groupNum);
                        //最低参团人数
                        map.put("min_man", minMan);
                        //最低折扣
                        map.put("min_price", minPrice);
                        //第一层级最高价
                        map.put("market_price", marketPrice);
                        //第一层级最高折扣价
                        map.put("kaiprice", kaiPrice);
                        //第一层级最高参团人数
                        map.put("groupnum", groupnum);
                        groupProductModels.add(map);
                    }
                }

            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("首页拼团商品流程出错");
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_SYPTSPLCCC, "首页拼团商品流程出错", "goGroup");
        }


        return groupProductModels;
    }

    @Override
    public Map<String, Object> getUserTell(MainVo vo) {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            //公告标题
            String systemMsgTitle = "";
            //系统公告
            String systemMsg = "";
            //公告类型 1=系统维护 2=升级公告 3--普通公告
            int systemMsgType = 0;
            //维护开始、结束时间
            String systemMsgStartDate = "";
            String systemMsgEndDate = "";
            String info = "";
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", 0);
            parmaMap.put("startDate_lt", new Date());
            parmaMap.put("endDate_gt", new Date());
            parmaMap.put("type_sort", DataUtils.Sort.ASC.toString());
            parmaMap.put("user_tell", SystemTellModel.TELL.YES);
            List<Map<String, Object>> systemList = systemTellModelMapper.selectDynamic(parmaMap);
            if (systemList.size() > 0) {
                Map<String, Object> systemMap = systemList.get(0);
                systemMsgType = MapUtils.getIntValue(systemMap, "type");
                systemMsgTitle = MapUtils.getString(systemMap, "title");
                systemMsg = MapUtils.getString(systemMap, "content");
                systemMsgEndDate = DateUtil.dateFormate(MapUtils.getString(systemMap, "enddate"), GloabConst.TimePattern.YMDHMS);
                systemMsgStartDate = DateUtil.dateFormate(MapUtils.getString(systemMap, "startdate"), GloabConst.TimePattern.YMDHMS);
                if (systemMsgType == 1){
                    info = "系统维护中";
                }
            }
            //系统公告
            resultMap.put("systemMsgTitle", systemMsgTitle);
            resultMap.put("systemMsg", systemMsg);
            resultMap.put("systemMsgType", systemMsgType);
            resultMap.put("systemMsgEndDate", systemMsgEndDate);
            resultMap.put("systemMsgStartDate", systemMsgStartDate);
            resultMap.put("info", info);
        }catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("获取平台用户公告");
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_SYPTSPLCCC, "获取平台用户公告 出错", "goGroup");
        }
        return resultMap;
    }

    @Override
    public void markToRead(MainVo vo, Integer tell_id) throws LaiKeAPIException{
        try {
            if (StringUtils.isEmpty(tell_id)){
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_CSCW, "参数错误", "markToRead");
            }
            User user = RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, true);
            publicSystemTellService.markToRead(vo, user.getUser_id(), tell_id, false);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("标记公告以读 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "markToRead");
        }
    }

    @Autowired
    private PublicSystemTellService publicSystemTellService;

    @Autowired
    PublicCouponService publicCouponService;

    @Autowired
    PubliceService publicService;

    @Autowired
    PluginsModelMapper pluginsModelMapper;

    @Autowired
    UserGradeModelMapper userGradeModelMapper;

    @Autowired
    ConfigModelMapper configModelMapper;

    @Autowired
    FilesRecordModelMapper filesRecordModelMapper;

    @Autowired
    UploadConfigModelMapper uploadConfigModelMapper;

    @Autowired
    BannerModelMapper bannerModelMapper;

    @Autowired
    ProductModelMapper productModelMapper;

    @Autowired
    ProductClassModelMapper productClassModelMapper;

    @Autowired
    ProductListModelMapper productListModelMapper;

    @Autowired
    ConfiGureModelMapper confiGureModelMapper;

    @Autowired
    SystemMessageModelMapper systemMessageModelMapper;

    @Autowired
    IntegralGoodsModelMapper integralGoodsModelMapper;

    @Autowired
    IntegralConfigModelMapper integralConfigModelMapper;

    @Autowired
    MchModelMapper mchModelMapper;

    @Autowired
    MchStoreModelMapper mchStoreModelMapper;

    @Autowired
    GroupProductModelMapper groupProductModelMapper;

    @Autowired
    SecondsConfigModelMapper secondsConfigModelMapper;

    @Autowired
    SecondsProModelMapper secondsProModelMapper;

    @Autowired
    SignConfigModelMapper signConfigModelMapper;

    @Autowired
    SignRecordModelMapper signRecordModelMapper;


    @Autowired
    ProductConfigModelMapper productConfigModelMapper;

    @Autowired
    AdminCgModelMapper adminCgModelMapper;

    @Autowired
    RedisUtil redisUtil;

    @Autowired
    UserBaseMapper userBaseMapper;

    @Autowired
    GuideModelMapper guideModelMapper;

    @Autowired
    private ActivityModelMapper activityModelMapper;

    @Autowired
    private ActivityProModelMapper activityProModelMapper;

    @Autowired
    private PublicGoodsService publicGoodsService;

    @Autowired
    private PubliceGroupService publiceGroupService;

    @Autowired
    private PubliceBargainService publiceBargainService;

    @Autowired
    private PubliceAuctionService publiceAuctionService;

    @Autowired
    private PubliceIntegralService publiceIntegralService;

    @Autowired
    private UiNavigationBarModelMapper uiNavigationBarModelMapper;

    @Autowired
    private PubliceSubtractionService publiceSubtractionService;

    @Autowired
    private PubliceDistributionService publiceDistributionService;

    @Autowired
    private PublicMemberService publicMemberService;

    @Autowired
    private PublicDictionaryService publicDictionaryService;

    @Autowired
    private PreSellGoodsMapper preSellGoodsMapper;

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private MchConfigModelMapper mchConfigModelMapper;

    @Autowired
    private ProLabelModelMapper proLabelModelMapper;

    @Autowired
    private MemberConfigMapper memberConfigMapper;
    @Autowired
    private MchClassModelMapper mchClassModelMapper;

    @Autowired
    private CustomerModelMapper customerModelMapper;

    @Autowired
    private PublicMchService publicMchService;

    @Autowired
    private CouponConfigModelMapper couponConfigModelMapper;

    @Autowired
    private UserCollectionModelMapper userCollectionModelMapper;

    @Autowired
    private OrderDetailsModelMapper orderDetailsModelMapper;

    @Autowired
    private SystemTellModelMapper systemTellModelMapper;
}

